package com.saver.modules.home;

import com.saver.common.utils.R;
import com.saver.modules.sys.service.SysLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/home")
public class HomeController {

    @Autowired
    private SysLoginService sysLoginService;

    @GetMapping("/info")
    public R info() {
        Integer currentDayLoginCount = sysLoginService.getCurrentDayLoginCount();
        Integer allLoginCount = sysLoginService.getAllLoginCount();
        ArrayList<Object> list = new ArrayList<>();
        Map<String, Object> map = new HashMap<>();
        map.put("title", "今日登录");
        map.put("count", currentDayLoginCount);
        map.put("icon", "md-person");
        map.put("color", "#2d8cf0");
        list.add(map);
        Map<String, Object> two = new HashMap<>();
        two.put("title", "访问次数");
        two.put("count", allLoginCount);
        two.put("icon", "ios-pulse");
        two.put("color", "#19be6b");
        list.add(two);
        return R.ok().put("data", list);
    }
}
